<?php require_once('../../../../Connections/conexion.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form")) {
  $updateSQL = sprintf("UPDATE empresa SET dir_empresa=%s, tel_empresa=%s, logo_empresa=%s WHERE ` rif_empresa`=%s",
                       GetSQLValueString($_POST['dir_empresa'], "text"),
                       GetSQLValueString($_POST['tel_empresa'], "text"),
                       GetSQLValueString($_POST['logo_empresa'], "text"),
                       GetSQLValueString($_POST['rif_empresa'], "text"));

  mysql_select_db($database_conexion, $conexion);
  $Result1 = mysql_query($updateSQL, $conexion) or die(mysql_error());

  $updateGoTo = "mEmpresa.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

mysql_select_db($database_conexion, $conexion);
$query_mempresa = "SELECT * FROM empresa";
$mempresa = mysql_query($query_mempresa, $conexion) or die(mysql_error());
$row_mempresa = mysql_fetch_assoc($mempresa);
$totalRows_mempresa = mysql_num_rows($mempresa);
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Modificar Empresa</title>
<link rel="stylesheet" href="Formulario con estilo/jqtransform.css" type="text/css" media="all" />
<script src="Formulario con estilo/jquery.js"></script>
<script src="Formulario con estilo/jquery.jqtransform.js"></script>
<script>
$(function(){

$('form').jqTransform({ imgPath:'img/'});
});
</script>
<link href="../css/style.css" rel="stylesheet" type="text/css">
</head>
<form name="form"  target="content" action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" id="form">
     <div id="contenido">
      <div id="Titulo">
        <p>Modificar Empresa</p>
      </div>
                <table width="400" border="0" align="center">
               <tr>
                 <td> <label>RIF Empresa:</label></td>
                 <td><input name="rif_empresa" type="text" id="rif_empresa" readonly="readonly" /></td>
               </tr>
               <tr>
                 <td> <label for="nom_empresa">Nombre Empresa:</label></td>
                 <td><input type="text" name="nom_empresa" id="nom_empresa"></td>
               </tr>
               <tr>
                 <td><label for="dir_empresa">Dirección de Empresa:</label></td>
                 <td><input type="text" name="dir_empresa" id="dir_empresa"></td>
               </tr>
               <tr>
                 <td>   <label for="tel_empresa">Telefono:</label></td>
                 <td><input type="text" name="tel_empresa" id="tel_empresa" /></td>
               </tr>
               <tr>
                 <td>  <label for="cont_empresa">Persona Contacto:</label></td>
                 <td><input type="text" name="cont_empresa" id="cont_empresa" /></td>
               </tr>
               <tr>
                 <td>  <label for="correo_empresa">E-Mail Empresa:</label></td>
                 <td><input name="correo_empresa" type="text" id="correo_empresa" value="@hotmail.com"></td>
               </tr>
               <tr>
                 <td><label>Logo Empresa
                 </label></td>
                 <td>
                   <input type="file" name="logo_empresa" id="logo_empresa">
                </td>
               </tr>
               <tr>
                 <td><label>Icono empresa
                   
                 </label></td>
                 <td>
                   <input type="file" name="icono_empresa" id="icono_empresa">
                </td>
               </tr>
               <tr>
                 <td>&nbsp;</td>
                 <td>&nbsp;</td>
               </tr>
               <tr>
                 <td>&nbsp;</td>
                 <td><input type="button" value="Modificar" /></td>
               </tr>
             </table>
             <p>&nbsp;</p>
</div>
                         <div id="tabla5"></div>
          
           </div>
  </div>
      <div class="nofloat"></div>
      <input type="hidden" name="MM_update" value="form" />
    </div>
  </div>
</form>
<?php
mysql_free_result($mempresa);
?>
